package com.hhh.petadopt.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hhh.petadopt.pojo.Adopt;
import com.hhh.petadopt.pojo.AdoptVo;
import com.hhh.petadopt.service.AdminAdoptService;
import com.hhh.petadopt.utils.Page;

/**
 * 收养管理
 * @author 杜镇声声
 *
 */
@Controller
public class AdminAdoptcontroller {
	
	@Autowired
	private AdminAdoptService adminadoptservice;
	
	@RequestMapping(value="/adminAdopt/adoptlist.html")
	public String selectpage(AdoptVo Vo,Model model) {
		//执行查询
		Page<Adopt> page = adminadoptservice.selectAdopt(Vo);
		
		//将数据保存到域中
		model.addAttribute("page", page);
		model.addAttribute("total", page.getTotal());
		
		//搜索信息回显
		model.addAttribute("numm", Vo.getNumm());
		model.addAttribute("ispass", Vo.getIspass());
		
		
		
		return "admin/adopt";
	}
	//通过审核
	@RequestMapping(value="/adminAdopt/allowpass.html")
	@ResponseBody
	public String passallow(Integer id) {
		adminadoptservice.passw(id);
		return "ok";
	}
	//取消通过
	@RequestMapping(value="/adminAdopt/cancelPass.html")
	@ResponseBody
	public String cancelallow(Integer id) {
		adminadoptservice.cancelPass(id);
		
		return "ok";
	}
	//删除
	@RequestMapping(value="/adminAdopt/deladopt.html")
	@ResponseBody
	public String delAopt(Integer id) {
		adminadoptservice.deleteAdoptById(id);
		return "ok";
	}
	//删除多选
	@RequestMapping(value="/adminAdopt/deleteadopts.html")
	@ResponseBody
	public String deleteAdoptss(Integer[] ids) {
		adminadoptservice.deleteAdoptSByIds(ids);
		return "ok";
	}

}
